package controller

import (
	"hft/Database/admin"
	services "hft/Http/Services"
	utils "hft/Http/Utils"

	"github.com/gin-gonic/gin"
)

type Area struct{}

func (*Area) CreateArea(c *gin.Context) {
	var data *admin.Area

	c.ShouldBindJSON(&data)

	err := services.AreaService.CreateArea(data)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.Ok(c)
}

func (*Area) EditArea(c *gin.Context) {
	var data *admin.Area

	c.ShouldBindJSON(&data)

	err := services.AreaService.EditArea(data)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.Ok(c)
}

func (*Area) GetAreaList(c *gin.Context) {
	data, err := services.AreaService.GetAreaList()

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.OkWithData(data, c)

}

var AreaController = new(Area)
